//
//  CalenderCollectionCell.m
//  YZCCalender
//
//  Created by Jason on 2018/1/17.
//  Copyright © 2018年 jason. All rights reserved.
//

#import "CalenderCollectionCell.h"
#import "CalenderModel.h"

@interface CalenderCollectionCell()

@property (nonatomic, strong) UILabel *numberLabel;

@property (nonatomic, strong) UILabel *tipLabel; // 提示标签， 入住/离店

@end

@implementation CalenderCollectionCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        CGFloat numberHeight = 20;
        [self.contentView addSubview:self.numberLabel];
        [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(10);
            make.left.right.offset(0);
            make.height.offset(numberHeight);
        }];
        
        CGFloat top = 0.0;
        [self.contentView addSubview:self.tipLabel];
        [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.offset(0);
            make.top.equalTo(self.numberLabel.mas_bottom).offset(top);
        }];
    }
    return self;
}

- (void)changeContentBackgroundStatus:(BOOL)isBetween {
    if (isBetween) {
        self.contentView.backgroundColor = MSThemeColorA(0.1);
    } else {
        self.contentView.backgroundColor = [UIColor whiteColor];
    }
}

- (void)changeContentBackGroundStatus:(NSInteger)inOutStatus {
    if (inOutStatus == 0) {
        // 默认
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.numberLabel.textColor = [UIColor colorWithHexString:@"#444444"];
    } else if (inOutStatus == 1) {
        // 入住
        self.contentView.backgroundColor = MSThemeColor;
        self.numberLabel.textColor = [UIColor whiteColor];
        self.tipLabel.text = @"入住";
    } else if (inOutStatus == 2) {
        self.contentView.backgroundColor = MSThemeColor;
        self.numberLabel.textColor = [UIColor whiteColor];
        self.tipLabel.text = @"退房";
    }
}

#pragma mark - Getters And Setters

- (UILabel *)numberLabel {
    if (_numberLabel == nil) {
        _numberLabel                 = [[UILabel alloc] init];
        _numberLabel.textAlignment   = NSTextAlignmentCenter;
        _numberLabel.font            = [UIFont systemFontOfSize:14];
    }
    return _numberLabel;
}

- (UILabel *)tipLabel {
    if (!_tipLabel) {
        _tipLabel = [[UILabel alloc] init];
        _tipLabel.font = [UIFont systemFontOfSize:10];
        _tipLabel.text = @"入住";
        _tipLabel.textColor = [UIColor whiteColor];
        _tipLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _tipLabel;
}

- (void)setModel:(CalenderModel *)model {
    _model = model;
    self.numberLabel.text = model.day;
    if (!model.enableSelect) {
        self.numberLabel.textColor = rgba(0, 0, 0, 0.3);
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.tipLabel.hidden = NO;
    } else if (model.selectType == 0) {
        self.numberLabel.textColor = [UIColor colorWithHexString:@"#444444"];
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.tipLabel.hidden = NO;
    } else if (model.selectType == 1) {
        self.numberLabel.textColor = [UIColor colorWithHexString:@"#444444"];
        self.contentView.backgroundColor = MSThemeColorA(0.2);
        self.tipLabel.hidden = YES;
    } else if (model.selectType == 2) {
        self.numberLabel.textColor = [UIColor whiteColor];
        self.tipLabel.text = @"入住";
        self.contentView.backgroundColor = MSThemeColor;
        self.tipLabel.hidden = NO;
    } else if (model.selectType == 3) {
        self.numberLabel.textColor = [UIColor whiteColor];
        self.tipLabel.text = @"退房";
        self.contentView.backgroundColor = MSThemeColor;
        self.tipLabel.hidden = NO;
    }
}


-(void)addAnimaiton{
    CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
    
    
    anim.values = @[@0.6,@1.2,@1.0];
    anim.keyPath = @"transform.scale";  // transform.scale 表示长和宽都缩放
    anim.calculationMode = kCAAnimationPaced;
    anim.duration = 0.25;
    [self.numberLabel.layer addAnimation:anim forKey:nil];
}
@end

